********************************************************************************
* Purpose: Imams data analysis - scaleup Eid ul Azha 2020 
* Sub-file: Three group HTE baseline beliefs 
********************************************************************************

	****************************************************************************
	* Load data
	****************************************************************************

	use			"${imamsurvey}/merged_scaleup.dta" , clear 
	
	keep		if consent_statement==1											// Restrict the sample here to people who responded in the baseline / T calls
																				
	
	****************************************************************************
	* Estimates
	****************************************************************************\
	
	estimates	clear 
		
	local		j = 0 
	
	foreach		i in $msoutcomes {
	
				local 		j = `j' + 1
	
				reg 		`i' treat_group1 treat_group2 treat_group3 ///
								i.bl3groups , robust 
					
				sum 		`i' if bl3groups==1 & treatment_any==0 &  e(sample) 
				estadd		scalar mean1 = round(r(mean) , .01) 				
								
				sum 		`i' if bl3groups==2 & treatment_any==0 &  e(sample) 
				estadd		scalar mean2 = round(r(mean) , .01) 				

				sum 		`i' if bl3groups==3 & treatment_any==0 &  e(sample) 
				estadd		scalar mean3 = round(r(mean) , .01) 	
				
				test		treat_group1 = treat_group2 = treat_group3 
				estadd 		scalar pvaldiff = r(p) 
				
				sum			bl3groups_1 if e(sample) 
				estadd		scalar prop1 = round(r(mean) , .01) 				

				sum			bl3groups_2 if e(sample) 
				estadd		scalar prop2 = round(r(mean) , .01) 				

				sum			bl3groups_3 if e(sample) 
				estadd		scalar prop3 = round(r(mean) , .01) 				
				
				est 		sto groups`j' 
	
	}

	****************************************************************************
	* Table 
	****************************************************************************
	
	esttab		groups* ///
					using "${texrct}/scaleup_ms_hte_groups.tex" , ///
					replace star(* .1 ** .05 *** .01) se  t(3) b(3) label ///
					scalars( ///
					"mean1 Control mean - certain and correct" ///
					"mean2 Control mean - uncertain" ///
					"mean3 Control mean - certain and wrong" ///
					"prop1 Proportion of sample - certain and correct" ///
					"prop2 Proportion of sample - uncertain" ///
					"prop3 Proportion of sample - certain and wrong" ///					
					"pvaldiff P-value - TE equal on all groups") ///
					keep(treat*) ///
					nonotes fragment booktabs 

	
